# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Aaron Griffin <aaron@archlinux.org>
# Original TU: Jeff Mickey <j@codemac.net>
# Contributor: ciccio.a

pkgname=squashfs-tools
pkgver=4.5
pkgrel=1
pkgdesc="Tools for squashfs, a highly compressed read-only filesystem for Linux."
url="https://github.com/plougher/squashfs-tools"
license=('GPL2')
arch=('x86_64')
depends=('lz4' 'lzo' 'xz' 'zlib' 'zstd')
source=("https://github.com/plougher/squashfs-tools#tag=${pkgver/_/-}")
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/plougher/${pkgname}/archive/refs/tags/${pkgver}.tar.gz"
        "${pkgname}-4.5-symlink_install.patch")
sha512sums=('e00610487d24eed9e5dadcf84014a3d7faa9815d8ce00fd4660e6c8ce394dccf185ed9f387f4fa1313b9812fe770f802bdcbaef87887f2bcefacf234594a72e0'
            'c2c77fb3741b75c2921ec6402d3532f87fd3d83e0e7042d88cf18835e30264547ce30b228bf5c0e5819075134871d27e2c8c5418257cbc66bfbfb730ef59a792')
b2sums=('2fc8ab9bb6565b97656afd63b76bfd7449d96b83697286e88b55a8cd82957b395df17a707ee93e8a99ed19dc5ba73966ce33530ef6c35797924dad4e3f16ed3b'
        'd19e07109630eb10952630611a0ebdc1349585a89bed29341c9b7a623e7d165e3c047332396edd4ababe3516010289e2743e8dc09be733f464e216fffd09036e')

prepare() {
  cd  ${pkgname}-${pkgver}
  # fix the creation of symlinks in install target
  patch -Np1 -i "../${pkgname}-4.5-symlink_install.patch"
}

build() {
  make -C ${pkgname}-${pkgver}/${pkgname} \
    GZIP_SUPPORT=1 \
    XZ_SUPPORT=1 \
    LZO_SUPPORT=1 \
    LZMA_XZ_SUPPORT=1 \
    LZ4_SUPPORT=1 \
    ZSTD_SUPPORT=1 \
    XATTR_SUPPORT=1
}

package() {
  make -C ${pkgname}-${pkgver}/${pkgname} install INSTALL_DIR="${pkgdir}/usr/bin"
}
